package com.rw.coco.reply.impl;

import com.rw.coco.api.reply.mapper.EntertainingReply;
import com.rw.coco.handler.message.event.CocoMessageEvent;
import com.rw.coco.reply.constants.AdvanceReplyKey;
import com.rw.coco.reply.constants.EntertainingReplyKey;
import com.rw.coco.reply.reader.CocoPropertiesReader;
import com.rw.tool.util.random.RandomUtil;

public class PropertiesEntertainingReply implements EntertainingReply {
    private final CocoPropertiesReader reader;

    public PropertiesEntertainingReply(CocoPropertiesReader reader) {
        this.reader = reader;
    }

    @Override
    public String getBotName() {
        return reader.get(AdvanceReplyKey.BOT_NAME);
    }

    @Override
    public String callTheBotName(CocoMessageEvent event) {
        String cocoReply = reader.get(EntertainingReplyKey.COCO_REPLY);
        String[] split = cocoReply.split("\n");
        int index = RandomUtil.nextInt(split.length);
        return split[index];
    }
}
